Skip to content

feat: add accountOverride to override default recipient or delegator for MM Pay transactions#8454

Merged
jpuri merged 31 commits intomainfrom
acc_override_support
Apr 23, 2026
Merged

feat: add accountOverride to override default recipient or delegator for MM Pay transactions#8454
jpuri merged 31 commits intomainfrom
acc_override_support

Conversation

@jpuri
Copy link
Copy Markdown
Contributor

@jpuri jpuri commented Apr 14, 2026

Explanation

Add accountOverride in transaction config to override default recipient or delegator for MM Pay transactions

References

Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1188
Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1204

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes which account is used for balance checks and transaction/delegation signing, so incorrect wiring could cause quotes to be computed for the wrong account or submissions to be signed with an unexpected from.

Overview
Adds a new per-transaction accountOverride config/state field that overrides the default from address used across MM Pay flows.

When accountOverride changes, the controller now re-runs source amount/quote updates and clears any selected paymentToken; quote building, payment-token balance lookups, Relay execute delegation (txParams.from), and HyperLiquid withdraw signing now all use the overridden address. Tests and changelog are updated accordingly.

Reviewed by Cursor Bugbot for commit 2383954. Bugbot is set up for automated code reviews on this repo. Configure here.

@jpuri jpuri marked this pull request as ready for review April 15, 2026 09:46
@jpuri jpuri requested review from a team as code owners April 15, 2026 09:46
@jpuri jpuri enabled auto-merge April 15, 2026 09:46
Comment thread packages/transaction-pay-controller/src/TransactionPayController.ts Outdated
Comment thread packages/transaction-pay-controller/src/strategy/across/across-actions.ts Outdated
Comment thread packages/transaction-pay-controller/src/types.ts Outdated
Comment thread packages/transaction-pay-controller/src/utils/quotes.ts Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the fully gasless flow, do we need to update submitViaRelayExecute in relay-submit to use the accountOverride also since it would be providing the funds?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also already work as from is now updated in quote.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow just uses the transaction and not from so I think we need to fix this manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is updated to address this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do in a separate PR if easier, but for the withdraw flows, if we have a accountOverride, then we want that to sign the withdraw transaction rather than the original from.

So do we need to convert the withdraw transaction data to delegations on line 353 of relay-submit.ts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also already work since from is quote is updated.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a special case as while the data is currently using the original from via transaction which is what we want, we now need to convert it to delegations with getDelegationTransaction so our accountOverride can submit it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is updated to address this

Comment thread packages/transaction-pay-controller/src/strategy/relay/relay-quotes.ts Outdated
@jpuri jpuri requested a review from matthewwalsh0 April 15, 2026 12:07
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1b7f538. Configure here.

Comment thread packages/transaction-pay-controller/src/TransactionPayController.ts
/**
* Optional address to override the default account used by the transaction.
* When `isPostQuote` is true, used as the recipient of the MM Pay transfer.
* When `isPostQuote` is false, used as the delegator for the transaction, it provides the funds and pays for gas.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly ambigious as the delegation is still done on behalf of the original from and not accountOverride. Plus this also still applies when isPostQuote is true.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point, I updated the PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow just uses the transaction and not from so I think we need to fix this manually.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a special case as while the data is currently using the original from via transaction which is what we want, we now need to convert it to delegations with getDelegationTransaction so our accountOverride can submit it.

@jpuri
Copy link
Copy Markdown
Contributor Author

jpuri commented Apr 17, 2026

This is also a special case as while the data is currently using the original from via transaction which is what we want, we now need to convert it to delegations with getDelegationTransaction so our accountOverride can submit it.

@matthewwalsh0 : PR is updated to address this.

@matthewwalsh0
Copy link
Copy Markdown
Member

@metamaskbot publish-preview

@jpuri jpuri requested a review from matthewwalsh0 April 22, 2026 10:28
@jpuri jpuri added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 365e867 Apr 23, 2026
358 checks passed
@jpuri jpuri deleted the acc_override_support branch April 23, 2026 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants